/* Copyright (C) 2010 Fredrique Samuels, fredriquesamuels@gmail.com */

/*
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "mouse_event.h"

namespace tri {

TMouseEvent TMouseEvent::s_CurrentEvent = TMouseEvent();
TMouseEvent TMouseEvent::s_LastEvent = TMouseEvent();

TMouseEvent::TMouseEvent(int _x, int _y, int _x_rel, int _y_rel, int _button,
		int _event) :
	x(_x), y(_y), x_rel(_x_rel), y_rel(_y_rel), button(_button), event(_event){
}

TMouseEvent::~TMouseEvent() {
}

void TMouseEvent::copy(const TMouseEvent& src, TMouseEvent&dst) {
	dst.x = src.x;
	dst.y = src.y;
	dst.x_rel = src.x_rel;
	dst.y_rel = src.y_rel;
	dst.button = src.button;
	dst.event = src.event;
	dst.IDList.clear();
	for (unsigned int i=0;i<src.IDList.size();i++){
		dst.IDList.push_back(src.IDList[i]);
	}
}

void TMouseEvent::set(int _x, int _y, int _x_rel, int _y_rel,
			int _button, int _event){
	x = _x;
	y = _y;
	x_rel = _x_rel;
	y_rel = _y_rel;
	button = _button;
	event = _event;
	IDList.clear();
}

int TMouseEvent::getX() const{
	return x;
}

int TMouseEvent::getY() const{
	return y;
}

int TMouseEvent::getRelativeX() const{
	return x_rel;
}

int TMouseEvent::getRelativeY() const{
	return y_rel;
}

int TMouseEvent::getButton() const{
	return button;
}

int TMouseEvent::getEvent() const{
	return event;
}

void TMouseEvent::getIDList(std::vector<unsigned int>& list){
	list.clear();
	for (unsigned int i=0;i<IDList.size();i++){
		list.push_back(IDList[i]);
	}
}

TMouseEvent TMouseEvent::getCurrentEvent() {
	return TMouseEvent::s_CurrentEvent;
}

TMouseEvent TMouseEvent::getLastEvent() {
	return TMouseEvent::s_LastEvent;
}

std::string TMouseEvent::toString() const {
	std::string out = "";
	out+="<Mouse Event  x=";
	out+=utils::int2String(getX());
	out+=" y=";
	out+=utils::int2String(getY());
	out+=" x_rel=";
	out+=utils::int2String(getRelativeX());
	out+=" y_rel=";
	out+=utils::int2String(getRelativeY());
	out+=" button=";
	out+=utils::int2String(getButton());
	out+=" event=";
	out+=utils::int2String(getEvent());
	out+=" >";
	return out;
}

}




